﻿using System;
using System.Collections.Generic;
using System.ComponentModel.DataAnnotations;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using PMS.XCMG.Util;
using Microsoft.EntityFrameworkCore;
using Microsoft.EntityFrameworkCore.Metadata.Builders;

namespace PMS.XCMG.Entity
{
    /// <summary>
    /// 角色操作权限
    /// </summary>
    public partial class Sys_RoleAction
    {
        public string RoleId { get; set; }
        public string ActionId { get; set; }
    }

    public partial class Sys_RoleAction
    {
        public Sys_Role Role { get; set; }
        public Sys_Action Action { get; set; }
    }

    /// <summary>
    /// 实体配置
    /// OnModelCreating
    /// </summary>
    public class Sys_RoleActionTypeConfig : IEntityTypeConfiguration<Sys_RoleAction>
    {
        public void Configure(EntityTypeBuilder<Sys_RoleAction> builder)
        {
            #region 主外键关系
            builder.HasKey(t => new { t.ActionId, t.RoleId });
            builder.HasOne(ur => ur.Role).WithMany().HasForeignKey(k => k.RoleId);
            builder.HasOne(ur => ur.Action).WithMany().HasForeignKey(k => k.ActionId);
            #endregion

            #region 字段属性:最大长度,是否必需,默认值
            builder.Property(p => p.ActionId).HasMaxLength(EntityDefinition.DefSmallColLen);
            builder.Property(p => p.RoleId).HasMaxLength(EntityDefinition.DefSmallColLen);
            #endregion

            #region 备注
            builder.HasComment("角色操作权限");
            #endregion

            #region 种子数据

            #region 生产调度
            builder.HasData(
                new Sys_RoleAction() { RoleId = "1", ActionId = "40101" },
                new Sys_RoleAction() { RoleId = "1", ActionId = "40102" },
                new Sys_RoleAction() { RoleId = "1", ActionId = "40103" },
                new Sys_RoleAction() { RoleId = "1", ActionId = "40104" },
                new Sys_RoleAction() { RoleId = "1", ActionId = "40105" }
            );

            builder.HasData(
                new Sys_RoleAction() { RoleId = "1", ActionId = "40201" },
                new Sys_RoleAction() { RoleId = "1", ActionId = "40202" },
                new Sys_RoleAction() { RoleId = "1", ActionId = "40203" },
                new Sys_RoleAction() { RoleId = "1", ActionId = "40204" },
                new Sys_RoleAction() { RoleId = "1", ActionId = "40205" }
            );

            builder.HasData(
                new Sys_RoleAction() { RoleId = "1", ActionId = "40301" },
                new Sys_RoleAction() { RoleId = "1", ActionId = "40302" },
                new Sys_RoleAction() { RoleId = "1", ActionId = "40303" },
                new Sys_RoleAction() { RoleId = "1", ActionId = "40304" },
                new Sys_RoleAction() { RoleId = "1", ActionId = "40305" }
            );

            builder.HasData(
                new Sys_RoleAction() { RoleId = "1", ActionId = "40401" },
                new Sys_RoleAction() { RoleId = "1", ActionId = "40402" },
                new Sys_RoleAction() { RoleId = "1", ActionId = "40403" },
                new Sys_RoleAction() { RoleId = "1", ActionId = "40404" },
                new Sys_RoleAction() { RoleId = "1", ActionId = "40405" }
            );
            #endregion

            #region 生产工艺
            builder.HasData(
                new Sys_RoleAction() { RoleId = "1", ActionId = "50101" },
                new Sys_RoleAction() { RoleId = "1", ActionId = "50102" },
                new Sys_RoleAction() { RoleId = "1", ActionId = "50103" },
                new Sys_RoleAction() { RoleId = "1", ActionId = "50104" },
                new Sys_RoleAction() { RoleId = "1", ActionId = "50105" }
            );

            builder.HasData(
                new Sys_RoleAction() { RoleId = "1", ActionId = "50201" },
                new Sys_RoleAction() { RoleId = "1", ActionId = "50202" },
                new Sys_RoleAction() { RoleId = "1", ActionId = "50203" },
                new Sys_RoleAction() { RoleId = "1", ActionId = "50204" },
                new Sys_RoleAction() { RoleId = "1", ActionId = "50205" }
            );

            builder.HasData(
                new Sys_RoleAction() { RoleId = "1", ActionId = "50301" },
                new Sys_RoleAction() { RoleId = "1", ActionId = "50302" },
                new Sys_RoleAction() { RoleId = "1", ActionId = "50303" },
                new Sys_RoleAction() { RoleId = "1", ActionId = "50304" },
                new Sys_RoleAction() { RoleId = "1", ActionId = "50305" }
            );

            builder.HasData(
                new Sys_RoleAction() { RoleId = "1", ActionId = "50401" },
                new Sys_RoleAction() { RoleId = "1", ActionId = "50402" },
                new Sys_RoleAction() { RoleId = "1", ActionId = "50403" },
                new Sys_RoleAction() { RoleId = "1", ActionId = "50404" },
                new Sys_RoleAction() { RoleId = "1", ActionId = "50405" }
            );

            builder.HasData(
                new Sys_RoleAction() { RoleId = "1", ActionId = "50601" },
                new Sys_RoleAction() { RoleId = "1", ActionId = "50602" },
                new Sys_RoleAction() { RoleId = "1", ActionId = "50603" },
                new Sys_RoleAction() { RoleId = "1", ActionId = "50604" },
                new Sys_RoleAction() { RoleId = "1", ActionId = "50605" }
            );
            #endregion

            #region 产线配置
            builder.HasData(
                new Sys_RoleAction() { RoleId = "1", ActionId = "60101" },
                new Sys_RoleAction() { RoleId = "1", ActionId = "60102" },
                new Sys_RoleAction() { RoleId = "1", ActionId = "60103" },
                new Sys_RoleAction() { RoleId = "1", ActionId = "60104" },
                new Sys_RoleAction() { RoleId = "1", ActionId = "60105" }
            );

            builder.HasData(
                new Sys_RoleAction() { RoleId = "1", ActionId = "60201" },
                new Sys_RoleAction() { RoleId = "1", ActionId = "60202" },
                new Sys_RoleAction() { RoleId = "1", ActionId = "60203" },
                new Sys_RoleAction() { RoleId = "1", ActionId = "60204" },
                new Sys_RoleAction() { RoleId = "1", ActionId = "60205" }
            );

            builder.HasData(
                new Sys_RoleAction() { RoleId = "1", ActionId = "60301" },
                new Sys_RoleAction() { RoleId = "1", ActionId = "60302" },
                new Sys_RoleAction() { RoleId = "1", ActionId = "60303" },
                new Sys_RoleAction() { RoleId = "1", ActionId = "60304" },
                new Sys_RoleAction() { RoleId = "1", ActionId = "60305" }
            );

            builder.HasData(
                new Sys_RoleAction() { RoleId = "1", ActionId = "60401" },
                new Sys_RoleAction() { RoleId = "1", ActionId = "60402" },
                new Sys_RoleAction() { RoleId = "1", ActionId = "60403" },
                new Sys_RoleAction() { RoleId = "1", ActionId = "60404" },
                new Sys_RoleAction() { RoleId = "1", ActionId = "60405" }
            );

            builder.HasData(
                new Sys_RoleAction() { RoleId = "1", ActionId = "60501" },
                new Sys_RoleAction() { RoleId = "1", ActionId = "60502" },
                new Sys_RoleAction() { RoleId = "1", ActionId = "60503" },
                new Sys_RoleAction() { RoleId = "1", ActionId = "60504" },
                new Sys_RoleAction() { RoleId = "1", ActionId = "60505" }
            );

            builder.HasData(
                new Sys_RoleAction() { RoleId = "1", ActionId = "60601" },
                new Sys_RoleAction() { RoleId = "1", ActionId = "60602" },
                new Sys_RoleAction() { RoleId = "1", ActionId = "60603" },
                new Sys_RoleAction() { RoleId = "1", ActionId = "60604" },
                new Sys_RoleAction() { RoleId = "1", ActionId = "60605" }
            );            
            #endregion

            #region 班组管理
            builder.HasData(
                new Sys_RoleAction() { RoleId = "1", ActionId = "70101" },
                new Sys_RoleAction() { RoleId = "1", ActionId = "70102" },
                new Sys_RoleAction() { RoleId = "1", ActionId = "70103" },
                new Sys_RoleAction() { RoleId = "1", ActionId = "70104" },
                new Sys_RoleAction() { RoleId = "1", ActionId = "70105" }
            );

            builder.HasData(
                new Sys_RoleAction() { RoleId = "1", ActionId = "70201" },
                new Sys_RoleAction() { RoleId = "1", ActionId = "70202" },
                new Sys_RoleAction() { RoleId = "1", ActionId = "70203" },
                new Sys_RoleAction() { RoleId = "1", ActionId = "70204" },
                new Sys_RoleAction() { RoleId = "1", ActionId = "70205" }
            );

            builder.HasData(
                new Sys_RoleAction() { RoleId = "1", ActionId = "70301" },
                new Sys_RoleAction() { RoleId = "1", ActionId = "70302" },
                new Sys_RoleAction() { RoleId = "1", ActionId = "70303" },
                new Sys_RoleAction() { RoleId = "1", ActionId = "70304" },
                new Sys_RoleAction() { RoleId = "1", ActionId = "70305" }
            );
            #endregion

            #region 物料管理
            builder.HasData(
                new Sys_RoleAction() { RoleId = "1", ActionId = "80101" },
                new Sys_RoleAction() { RoleId = "1", ActionId = "80102" },
                new Sys_RoleAction() { RoleId = "1", ActionId = "80103" },
                new Sys_RoleAction() { RoleId = "1", ActionId = "80104" },
                new Sys_RoleAction() { RoleId = "1", ActionId = "80105" }
            );

            builder.HasData(
                new Sys_RoleAction() { RoleId = "1", ActionId = "80201" },
                new Sys_RoleAction() { RoleId = "1", ActionId = "80202" },
                new Sys_RoleAction() { RoleId = "1", ActionId = "80203" },
                new Sys_RoleAction() { RoleId = "1", ActionId = "80204" },
                new Sys_RoleAction() { RoleId = "1", ActionId = "80205" }
            );

            builder.HasData(
                new Sys_RoleAction() { RoleId = "1", ActionId = "80301" },
                new Sys_RoleAction() { RoleId = "1", ActionId = "80302" },
                new Sys_RoleAction() { RoleId = "1", ActionId = "80303" },
                new Sys_RoleAction() { RoleId = "1", ActionId = "80304" },
                new Sys_RoleAction() { RoleId = "1", ActionId = "80305" },
                new Sys_RoleAction() { RoleId = "1", ActionId = "80306" }
            );
            #endregion

            #region 系统管理

            builder.HasData(
                new Sys_RoleAction() { RoleId = "1", ActionId = "90101" },
                new Sys_RoleAction() { RoleId = "1", ActionId = "90102" },
                new Sys_RoleAction() { RoleId = "1", ActionId = "90103" },
                new Sys_RoleAction() { RoleId = "1", ActionId = "90104" },
                new Sys_RoleAction() { RoleId = "1", ActionId = "90105" }
            );

            builder.HasData(
                new Sys_RoleAction() { RoleId = "1", ActionId = "90201" },
                new Sys_RoleAction() { RoleId = "1", ActionId = "90202" },
                new Sys_RoleAction() { RoleId = "1", ActionId = "90203" },
                new Sys_RoleAction() { RoleId = "1", ActionId = "90204" },
                new Sys_RoleAction() { RoleId = "1", ActionId = "90205" },
                new Sys_RoleAction() { RoleId = "1", ActionId = "90206" }
            );

            builder.HasData(
                new Sys_RoleAction() { RoleId = "1", ActionId = "90301" },
                new Sys_RoleAction() { RoleId = "1", ActionId = "90302" },
                new Sys_RoleAction() { RoleId = "1", ActionId = "90303" },
                new Sys_RoleAction() { RoleId = "1", ActionId = "90304" },
                new Sys_RoleAction() { RoleId = "1", ActionId = "90305" },
                new Sys_RoleAction() { RoleId = "1", ActionId = "90306" }
            );

            builder.HasData(
                new Sys_RoleAction() { RoleId = "1", ActionId = "90401" },
                new Sys_RoleAction() { RoleId = "1", ActionId = "90402" },
                new Sys_RoleAction() { RoleId = "1", ActionId = "90403" },
                new Sys_RoleAction() { RoleId = "1", ActionId = "90404" },
                new Sys_RoleAction() { RoleId = "1", ActionId = "90405" },
                new Sys_RoleAction() { RoleId = "1", ActionId = "90406" }
            );

            builder.HasData(
                new Sys_RoleAction() { RoleId = "1", ActionId = "90501" },
                new Sys_RoleAction() { RoleId = "1", ActionId = "90502" },
                new Sys_RoleAction() { RoleId = "1", ActionId = "90503" },
                new Sys_RoleAction() { RoleId = "1", ActionId = "90504" },
                new Sys_RoleAction() { RoleId = "1", ActionId = "90505" }
            );

            builder.HasData(
                new Sys_RoleAction() { RoleId = "1", ActionId = "90601" },
                new Sys_RoleAction() { RoleId = "1", ActionId = "90602" },
                new Sys_RoleAction() { RoleId = "1", ActionId = "90603" },
                new Sys_RoleAction() { RoleId = "1", ActionId = "90604" }
            );

            builder.HasData(
                new Sys_RoleAction() { RoleId = "1", ActionId = "90701" },
                new Sys_RoleAction() { RoleId = "1", ActionId = "90702" },
                new Sys_RoleAction() { RoleId = "1", ActionId = "90703" },
                new Sys_RoleAction() { RoleId = "1", ActionId = "90704" },
                new Sys_RoleAction() { RoleId = "1", ActionId = "90705" }
            );
            #endregion

            #endregion
        }
    }
}
